#ifndef SERVER_CONFIGURATION_H_
#define SERVER_CONFIGURATION_H_
#include <string>
#include "../Utils/index.h"
#include <log4cpp/Category.hh>
#include <log4cpp/FileAppender.hh>
#include <log4cpp/SimpleLayout.hh>
using namespace std;
extern log4cpp::Category& category;
class ServerCfg {
private:
	string path_cfg_file;
	string storage_path;
	unsigned int port;
public:
	ServerCfg(string* s) {
		this->path_cfg_file = *s;
	}
	ServerCfg(const ServerCfg& other) {
		this->path_cfg_file = other.path_cfg_file;
		this->port = other.port;
		this->storage_path = other.storage_path;
	}
	ServerCfg() {
	}

	~ServerCfg() {
	}

	//Levanta la configuracion desde el archivo
	void Initialize() {
		category.info("Reading cfg from file "+path_cfg_file);
		Index idx(&path_cfg_file);
		idx.LoadFromDisk();
		string p("PORT");
		string s("STORAGE_FOLDER");
		this->port=atoi(idx.GetSecond(&p).c_str());
		this->storage_path=idx.GetSecond(&s);
	}

	string GetStoragePath() {

		return storage_path;
	}

	unsigned int GetPort() {

		return this->port;
	}

};

#endif /* SERVER_CONFIGURATION_H_ */
